home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / nvlexp / mainform.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-12-05  |  10.7 KB  |  320 lines

  1. VERSION 2.00
  2. Begin Form MainForm 
  3.    Caption         =   "Novell DLL's Example Program"
  4.    ClientHeight    =   5475
  5.    ClientLeft      =   105
  6.    ClientTop       =   375
  7.    ClientWidth     =   6600
  8.    Height          =   5880
  9.    Icon            =   0
  10.    Left            =   45
  11.    LinkMode        =   1  'Source
  12.    LinkTopic       =   "Form1"
  13.    ScaleHeight     =   5475
  14.    ScaleWidth      =   6600
  15.    Top             =   30
  16.    Width           =   6720
  17.    Begin CommandButton Command3 
  18.       Caption         =   "Map Drives"
  19.       Height          =   375
  20.       Left            =   4620
  21.       TabIndex        =   11
  22.       Top             =   4800
  23.       Width           =   1215
  24.    End
  25.    Begin CommandButton Command2 
  26.       Caption         =   "Detach"
  27.       Height          =   375
  28.       Left            =   2940
  29.       TabIndex        =   4
  30.       Top             =   4800
  31.       Width           =   1215
  32.    End
  33.    Begin CommandButton Command1 
  34.       Caption         =   "Attach"
  35.       Height          =   375
  36.       Left            =   720
  37.       TabIndex        =   3
  38.       Top             =   4800
  39.       Width           =   1215
  40.    End
  41.    Begin ListBox List3 
  42.       Height          =   1590
  43.       Left            =   4470
  44.       TabIndex        =   5
  45.       Top             =   3030
  46.       Width           =   1485
  47.    End
  48.    Begin ListBox List2 
  49.       Height          =   1590
  50.       Left            =   2700
  51.       TabIndex        =   1
  52.       Top             =   3030
  53.       Width           =   1605
  54.    End
  55.    Begin ListBox List1 
  56.       Height          =   1590
  57.       Left            =   540
  58.       Sorted          =   -1  'True
  59.       TabIndex        =   0
  60.       Top             =   3030
  61.       Width           =   1605
  62.    End
  63.    Begin TextBox Text4 
  64.       Height          =   345
  65.       Left            =   4770
  66.       TabIndex        =   8
  67.       Text            =   "Text4"
  68.       Top             =   1620
  69.       Width           =   1215
  70.    End
  71.    Begin TextBox Text3 
  72.       Height          =   345
  73.       Left            =   2940
  74.       TabIndex        =   7
  75.       Text            =   "Text3"
  76.       Top             =   1620
  77.       Width           =   1215
  78.    End
  79.    Begin TextBox Text2 
  80.       Height          =   345
  81.       Left            =   450
  82.       TabIndex        =   6
  83.       Text            =   "Text2"
  84.       Top             =   1620
  85.       Width           =   1215
  86.    End
  87.    Begin TextBox Text1 
  88.       Height          =   345
  89.       Left            =   450
  90.       TabIndex        =   2
  91.       Text            =   "Text1"
  92.       Top             =   510
  93.       Width           =   1215
  94.    End
  95.    Begin TextBox Hidden2 
  96.       Height          =   285
  97.       Left            =   5370
  98.       TabIndex        =   10
  99.       Text            =   "Hidden2"
  100.       Top             =   360
  101.       Visible         =   0   'False
  102.       Width           =   1215
  103.    End
  104.    Begin TextBox Hidden1 
  105.       Height          =   315
  106.       Left            =   5370
  107.       TabIndex        =   9
  108.       Text            =   "Hidden1"
  109.       Top             =   30
  110.       Visible         =   0   'False
  111.       Width           =   1215
  112.    End
  113. DefInt A-Z
  114. Dim FileServerNames$(8)
  115. Sub Command1_Click ()
  116. '   ================================
  117. '   First check to see if already attached and if item is marked in List1
  118.     If MainForm.List1.ListIndex = -1 Then
  119.         Txt$ = "You must first select a server "
  120.         Txt$ = Txt$ + "to attach to!"
  121.         MsgBox Txt$, 32, "Must Pick Server"
  122.         Exit Sub
  123.     End If
  124.     TmpServer$ = MainForm.List1.List(List1.ListIndex)
  125.     For i% = 1 To 8
  126.         If TmpServer$ = MainForm.List2.List(i% - 1) Then
  127.             Txt$ = "You are already attached to "
  128.             Txt$ = Txt$ + "this server.  You must detach in "
  129.             Txt$ = Txt$ + "order to re-attach!"
  130.             MsgBox Txt$, 32, "Already Attached"
  131.             Exit Sub
  132.         End If
  133.     Next i%
  134. '   ================================
  135. '   Check to see if at least 1 of the 8 slots is empty
  136.     CanAdd% = False
  137.     For i% = 1 To 8
  138.         If FileServerNames$(i%) = "" Then
  139.             CanAdd% = True
  140.             Exit For
  141.         End If
  142.     Next i%
  143.         
  144.     If CanAdd% = False Then
  145.         Txt$ = "All 8 slots for attaching to "
  146.         Txt$ = Txt$ + "file servers are filled.  You "
  147.         Txt$ = Txt$ + "must de-attached from one of "
  148.         Txt$ = Txt$ + "before attaching to another "
  149.         Txt$ = Txt$ + "server!"
  150.         MsgBox Txt$, 32, "All Slots Filled"
  151.         Exit Sub
  152.     End If
  153. '   ================================
  154. '   Clear all 3 list boxes
  155.     ClearListBox List1
  156.     ClearListBox List2
  157.     ClearListBox List3
  158.     MainForm.Hidden1.Text = ""
  159.     MainForm.Hidden2.Text = ""
  160.     Password.Show 1
  161.     Unload Password
  162.     If MainForm.Hidden1.Text <> "***VOID***" Then
  163.         TempUserID$ = Hidden1.Text
  164.         UserPass$ = Hidden2.Text
  165.         Logon TmpServer$, TempUserID$, UserPass$
  166.     End If
  167.     UserID$ = MainForm.Text2.Text
  168.     FillOutLists UserID$
  169. End Sub
  170. Sub Command2_Click ()
  171. '   ================================
  172. '   First check to see if attached and if item is marked in List2
  173. '   Also, NEVER detach from Primary Server (#1 in list)
  174.     If MainForm.List2.ListIndex = -1 Then
  175.         Txt$ = "You must first select a server "
  176.         Txt$ = Txt$ + "to detach From!"
  177.         MsgBox Txt$, 32, "Must Pick Server"
  178.         Exit Sub
  179.     End If
  180.     TmpServer$ = MainForm.List2.List(List2.ListIndex)
  181.     TmpTxt$ = Text1.Text
  182.     If TmpServer$ = AllTrim(TmpTxt$) Then
  183.         Txt$ = "You cannot detach from your "
  184.         Txt$ = Txt$ + "Primary server!"
  185.         MsgBox Txt$, 32, "Critical Problem"
  186.         Exit Sub
  187.     End If
  188. '   ================================
  189. '   Clear all 3 list boxes
  190.     ClearListBox List1
  191.     ClearListBox List2
  192.     ClearListBox List3
  193.     Logoff TmpServer$
  194.     UserID$ = MainForm.Text2.Text
  195.     FillOutLists UserID$
  196. End Sub
  197. Sub Command3_Click ()
  198.     Map_Drv.Show 1
  199.     Unload Map_Drv
  200. End Sub
  201. Sub FillOutLists (UserID$)
  202.     ClearListBox List1
  203.     ClearListBox List2
  204.     ClearListBox List3
  205. '   ======================================================
  206. '   Get array of up to 255 servers that are available, and
  207. '   display them in List1
  208.     GetAllServers
  209.     For i% = 1 To UBound(WorkingServers$)
  210.         MainForm.List1.AddItem WorkingServers$(i%)
  211.     Next i%
  212. '   ======================================================
  213. '   Get array of up to 8 servers you can be attached to,
  214. '   and display them in List2 in their ordinal order 1 - 8
  215.     GetServerName FileServerNames$()
  216.     For i% = 1 To 8
  217.         If Len(FileServerNames$(i%)) > 0 Then
  218.             MainForm.List2.AddItem FileServerNames$(i%)
  219.         Else
  220.             MainForm.List2.AddItem "-- not attached --"
  221.         End If
  222.     Next i%
  223. '   ======================================================
  224. '   Get the userID on each of the 8 servers you are attached
  225. '   to, and display them in List3
  226.     MainForm.List3.AddItem UserID$
  227.     For i% = 2 To 8
  228.         If List2.List(i% - 1) <> "-- not attached --" Then
  229.             ConnectID% = i%
  230.             GetUser ConnectID%, TempUserID$
  231.             MainForm.List3.AddItem TempUserID$
  232.         Else
  233.             MainForm.List3.AddItem "-- N/A --"
  234.         End If
  235.     Next i%
  236. End Sub
  237. Sub Form_Load ()
  238.     CrLf$ = Chr$(13) + Chr$(10)     ' Since it is global, this
  239.                                     '   sets it for the program
  240.     MainForm.Show
  241.     MainForm.MousePointer = 11      ' #11 = hourglass
  242.     Form_Paint
  243. '   ======================================================
  244. '   Check to see if on a network, abort if not
  245.     CheckNet NetWork%
  246.     If NetWork% = False Then
  247.         Msg$ = "You must be running on a Novell Network in order"
  248.         Msg$ = Msg$ + " to run this program...."
  249.         MsgBox Msg$, 48, "Aborting Program"
  250.         Unload MainForm
  251.     End If
  252.                                                      
  253.     GetNovellParms CDate$, CTime$, UserID$      ' Get user info
  254.     MainForm.Text2.Text = UserID$
  255.     Text3.Text = CDate$
  256.     Text4.Text = CTime$
  257. '   ======================================================
  258. '   Check to see if got current version of all DLL's
  259.     If NetWork% = True Then
  260.         Suc% = False
  261.         GetNovellVer Suc%
  262.         If Suc% = False Then
  263.             Unload MainForm
  264.         End If
  265.     End If
  266. '   ======================================================
  267. '   Check to see if another copy of program is loaded, and
  268. '   abort if it is -- optional, but good defensive programming
  269. '   in many cases
  270.     hwd% = GetModuleHandle("Example.exe")
  271.     If GetModuleUsage(hwd%) > 1 Then
  272.         Msg$ = "Another copy of Example is loaded."
  273.         Msg$ = Msg$ + "  Only one copy of this program can run at one time."
  274.         Msg$ = Msg$ + Chr$(13) + Chr$(10) + Chr$(13) + Chr$(10)
  275.         Msg$ = Msg$ + "Abort loading this copy of Example!"
  276.         MsgBox Msg$, 48, "Another copy of program loaded!"
  277.         Unload MainForm
  278.     End If
  279. '   ======================================================
  280. '   Fill out lists 1 - 3
  281.     FillOutLists UserID$
  282. '   ======================================================
  283. '   Put the default server name in text box
  284.     Text1.Text = AllTrim(FileServerNames$(1))
  285. '   ======================================================
  286. '   Set mouse pointer back to arrow
  287.     Screen.MousePointer = 1
  288. End Sub
  289. Sub Form_Paint ()
  290.     Command1.Left = List1.Left + ((List1.Width - Command1.Width) \ 2)
  291.     Command2.Left = List2.Left + ((List2.Width - Command2.Width) \ 2)
  292.     Text1.Left = List1.Left
  293.     Text2.Left = List1.Left
  294.     MainForm.CurrentX = MainForm.List1.Left
  295.     MainForm.CurrentY = MainForm.List1.Top - 400
  296.     MainForm.Print "Available Servers:"
  297.     MainForm.CurrentX = MainForm.List2.Left
  298.     MainForm.CurrentY = MainForm.List2.Top - 400
  299.     MainForm.Print "Attached Servers:"
  300.     tempStr$ = "User ID:"
  301.     MainForm.CurrentX = MainForm.List3.Left + ((List3.Width - TextWidth(tempStr$)) \ 2)
  302.     MainForm.CurrentY = MainForm.List3.Top - 400
  303.     MainForm.Print tempStr$
  304.     MainForm.CurrentX = MainForm.Text1.Left
  305.     MainForm.CurrentY = MainForm.Text1.Top - 400
  306.     MainForm.Print "Primary Server:"
  307.     MainForm.CurrentX = MainForm.Text2.Left
  308.     MainForm.CurrentY = MainForm.Text2.Top - 400
  309.     MainForm.Print "User ID, Primary Server:"
  310.     MainForm.CurrentX = MainForm.Text3.Left
  311.     MainForm.CurrentY = MainForm.Text3.Top - 400
  312.     MainForm.Print "Login Date:"
  313.     MainForm.CurrentX = MainForm.Text4.Left
  314.     MainForm.CurrentY = MainForm.Text4.Top - 400
  315.     MainForm.Print "Login Time:"
  316. End Sub
  317. Sub Form_Unload (Cancel As Integer)
  318.     End
  319. End Sub
  320.